package com.ce.tag;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.ce.framework.util.DateUtil;
import com.ce.framework.util.LogUtil;
import com.ce.framework.util.StringUtil;
import com.ce.util.TreeNode;

public class YearSelectTag extends AbstractSelectTag {
	private static final long serialVersionUID = 1L;
	
	List<TreeNode> getContentList() {
		if(StringUtil.isBlank(value)&&(!blankOption&&!allOption)){
			value = DateUtil.format(new Date(),"yyyy");
		}
		Calendar c = Calendar.getInstance();
		int year = c.get(Calendar.YEAR);
		try {
			year = Integer.parseInt(value);
		} catch (NumberFormatException e) {
		}
		List<TreeNode> res = new ArrayList<TreeNode>();
		for(int i=-10;i<=10;i++){
			res.add(new TreeNode(""+(year+i),""+(year+i)));
		}
		return res;
	}

}
